Because it’s fun
Because it’s cool
Because it allows a new dimension of conveying results
Because a collaborator asked
plotly - especially ggplotly()
ggiraph
highcharter
Won’t cover
rCharts (ramnathv/rCharts)
rbokeh
leaflet
Many cases you know how to build a ggplot2 object
May want to “interactive” it up
Many times you will hit roadblocks or limitations
We’re going to be using the toyest example in R, mtcars ! But we want the car names
cars = mtcars %>%
rownames_to_column(var = "car") %>%
separate(car, into = c("make", "blah"), sep = " ", remove = FALSE, extra = "merge") %>%
select(make, car, everything()) %>%
select(-blah) %>%
as_tibble()
cars# A tibble: 32 × 13
make car mpg cyl disp hp drat wt qsec vs am gear carb
<chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 Mazda Mazd… 21 6 160 110 3.9 2.62 16.5 0 1 4 4
2 Mazda Mazd… 21 6 160 110 3.9 2.88 17.0 0 1 4 4
3 Dats… Dats… 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
4 Horn… Horn… 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
5 Horn… Horn… 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
6 Vali… Vali… 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
7 Dust… Dust… 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4
8 Merc Merc… 24.4 4 147. 62 3.69 3.19 20 1 0 4 2
9 Merc Merc… 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2
10 Merc Merc… 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4
# ℹ 22 more rows
Weight (in tons) vs miles per gallon (MPG)
plotly::ggplotly turns gg objects to plotly objects!
plotly::ggplotly turns your objects into plotly objects!
In ggiraph (giraffe) you cannot transform a ggplot object but you have the same syntax, but put an _interactive on it.
girafe it?Highcharts offers both a commercial license as well as a free non-commercial license
Possible to do within the same framework (e.g. Plotly)
Possible do to that with JavaScript only
Can use Shiny (see https://mastering-shiny.org/action-graphics.html)
Can also use crosstalk (https://rstudio.github.io/crosstalk/)
Must be a subset of certain htmlwidgets
DT - data tables